import {ref, reactive, computed} from "vue";

export function useStationForm() {
    const addDialogVisible = ref(false);      // 在这里定义
    const openAddDialog = () => {
        addDialogVisible.value = true;
        // 如果要重置表单，也可写在这里
    };

    const addForm = reactive({
        stationName: "",
        stationCode: "",
        stationType: "",
        stationProperty: "",
        enableEvaluation: 1,
        openTime: null,
        closeTime: null,
        address: "",
        stationIntro: "",
        stationImgUrl: "",
        createTime: new Date(),
        status: "正常",
        chargingPileCount: 0,
        chargingPiles: [],
    });

    const chargingPileCount = computed(() => {
        return Array.isArray(addForm.chargingPiles)
            ? addForm.chargingPiles.length
            : 0;
    });

    return {
        addForm,
        chargingPileCount,
        addDialogVisible,
        openAddDialog,
    };
}
